<div class="layui-fluid" id="VIEW-list-table" lay-title="货物列表">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">筛选数据</div>
                <div class="layui-card-body">
                    <form class="layui-form" lay-filter="lig-goods-searchform">
                        <div class="layui-inline">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="name" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <input type="button" class="layui-btn layui-btn-sm" lay-filter="lig-goods-search" lig-lang="btn-search" value="查询">
                            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary" lig-lang="btn-reset">重置</button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm" lay-filter="lig-goods-add">添加货物</div>
                        <div class="layui-btn layui-btn-sm layui-btn-primary" lay-filter="lig-goods-remove">删除</div>
                    </div>
                    <table lay-filter="lig-goods-table"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="tpl-row-toolBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs lig-modify" lay-event="lig-modify" title="修改">修改</a>
</script>
<script type="text/html" id="tpl-goods-add">
    <form class="layui-form" style="padding: 20px 20px 0 0;" lay-filter="lig-saveForm">
        <div class="layui-form-item">
            <label class="layui-form-label ligui-form-item-required">货物名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" autocomplete="off" class="layui-input" value='' lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label ligui-form-item-required">数量</label>
            <div class="layui-input-block">
                <input type="text" name="quantity" autocomplete="off" class="layui-input" value='' lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">重量</label>
            <div class="layui-input-block">
                <input type="text" name="weight" autocomplete="off" class="layui-input" value='' lay-verify="required">
            </div>
        </div>
    </form>
</script>
<script type="text/html" id="tpl-goods-modify">
    <form class="layui-form" style="padding: 20px 20px 0 0;" lay-filter="lig-saveForm">
        <input type="hidden" name="id" value="{{d.id}}"/>
        <div class="layui-form-item">
            <label class="layui-form-label ligui-form-item-required">货物名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" autocomplete="off" class="layui-input" value='{{d.name}}' lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label ligui-form-item-required">数量</label>
            <div class="layui-input-block">
                <input type="text" name="quantity" autocomplete="off" class="layui-input" value='{{d.quantity}}' lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">重量</label>
            <div class="layui-input-block">
                <input type="text" name="weight" autocomplete="off" class="layui-input" value='{{d.weight}}' lay-verify="required">
            </div>
        </div>
    </form>
</script>
<script>
    layui.use(['admin', 'table', 'form', 'dropdown', 'laytpl', 'jquery','lig'], function (admin, table, form, dropdown, laytpl, $, lig) {
        form.render();

        // 实例代码，加载字典项
        //lig.loadSelectDict('sku_splb', '[lay-filter="lig-goods-searchform"] select[name="splb"]');

        lig.table({
            elem: '[lay-filter="lig-goods-table"]',
            url: 'goods/page',
            cols: [[
                { title: '', type: 'checkbox', fixed: true, width: 60 },
                {title: '操作', toolbar: '#tpl-row-toolBar', align: 'left', width: 70},
                { title: '货物名称', field: 'name', width: 140 },
                { title: '数量', field: 'quantity', width: 140 },
                { title: '重量', field: 'weight', minWidth: 120 }

            ]]
        },{
            mode:'dialog',
            entity: 'goods',
            primaryField: 'id',
            addContent: $('#tpl-goods-add').html(),
            addUrl: 'goods/add',
            addTitle: '添加货物',
            area: ['50%', 'auto'],
            onAddOpened: function() {
            },

            modifyContent: $('#tpl-goods-modify').html(),
            modifyUrl: 'goods/modify',
            modifyTitle: '修改货物',
            area: ['50%', 'auto'],
            onModifyOpened: function() {
            },

            removeUrl: 'goods/remove',
            getUrl: 'goods/{id}'
        });

    })
</script>